<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width,initial-scale=1,user-scalable=0">
	<link rel="stylesheet" href="/c/Public/style/weui.min.css">
<link rel="stylesheet" href="/c/Public/style/price.css">

<title>菜单</title>
<script type="text/javascript" src="/c/Public/script/jquery-1.8.3.min.js"></script>
<style>
.bar{height:2.4rem;padding:0;}
.bar.mybars{height:2.4rem;background:#fbfbfb;border-top:1px solid #e6e6e6;text-align:right;padding-right:0.75rem;vertical-align: middle}
.bar.mybars.fk{padding-right:0;}
.bar.mybars a{display:inline-block;height:1.25rem;font-size:0.6rem;color:#fff;background:#f8ac19;line-height:1.25rem;padding:0 0.3rem;border-radius:5px;margin-top:0.5rem;margin-right:0.5rem;}
.bar.mybars a.jianyi{color:#999;background:none;border:none;padding:0;}
.bar.mybars a.button-fill{display:block;width:100%;height:100%;background: #ff7031;margin:0;border-radius:0;line-height:2.25rem;text-align:center;font-size:0.8rem;padding:0;}
.bar .button{padding-left:0.3rem;}

</style>

<script> 

	$(function(){
	 $("#clean").on("click", function (e) {
		   e.preventDefault();
	       var that = $(this);
	       var jqxhr = $.ajax({
	           type: "post",
	           url: "<?php echo U('Home/Index/cleanCart');?>",
	       }).done(function (res) {
	           if (res[0]) {
	               alert("发表成功！");
	           } else {
	              	alert(res[1]);
	              	$("#foot").find("b").text(res[1]);
	           }
	       }).fail(function () {
	           alert("发生内部错误！");
	       }).always(function () {
	       }) ; 
	   }
	   );		
		
	})
	function tianjia(id){
		// alert(id);
	 var jqxhr = $.ajax({
         type: "post",
         url: "<?php echo U('Home/Index/addItem');?>",
         data: {cid: id}
     }).done(function (res) {
         if (res[0]) {
             alert("发表成功！");
         } else {
             if(res[2]){
             	var r = confirm(res[1]);
					if (r == true) {
						window.location = "<?php echo U('/Home/User/login');?>?return_url="+window.location.href;
					} else {
						//取消按钮
					}
             }else{
            //	alert(res[1]);
			 	//location.reload();
			   //	document.getElementById("body").value = "评论成功";
				$("#foot").find("b").text('共计'+res[1]+'元');
         	}
         }
     }).fail(function () {
         alert("发生内部错误！");
     }).always(function () {
     }) ;  
	}
			
	
</script> 
</head>
<body>
	<!-- div style="text-align: center;">
		<img style="margen: 0 auto; width: 30%" src="<?php echo ($headimgurl); ?>" /><br>
		<br>
	</div> -->
<?php
foreach ( $result as $key => $value ) { ?>
	<div class="plans">
		<div class="plan">
			<h3 class="plan-title"><?php echo ($value['name']); ?></h3>
			<p class="plan-price">
			</p>
			<img alt="这里是图片"  style="margen: 0 auto; width: 30%" src="<?php echo ($value['pic']); ?>"><br>
			
			<ul class="plan-features">
				<li class="plan-feature"><span class="plan-feature-name">菜名</span> <?php echo ($value['name']); ?> </li>
				<li class="plan-feature"><span class="plan-feature-name">价格</span> <?php echo ($value['price']); ?></li>
			</ul>
			  <a href="javascript:void(0)" id = "cid"  cid = "<?php echo ($value['id']); ?>"  onclick ="tianjia(<?php echo ($value['id']); ?>)" class="plan-button" >快到碗里来</a> 
		</div>
	</div>
<?php
} ?>


 	<div id = "foot" class="bar bar-standard bar-footer mybars">
 			<b  class = "body" id = "body">
 			</b>
           <a class="external" href="<?php echo U('Home/Index/postCart');?>">提交订单</a>
            <a class="external jianyi"  id = "clean" href="javascript:void(0)">清空购物车</a>
     </div>
</body>

</html>